<form action="<?php echo $form['formSettings']['action']; ?>" method="post">
    
    <?php if (isset($id)) : ?>
    <input type="hidden" name="id" value="<?php echo $id; ?>" />
    <?php endif; ?>
    
    <?php foreach ($form as $kSect => $section):   // Each section ?>
        <?php if (!is_int($kSect)) continue;       // Removing entries that are not section ?>
        
        <?php if (!empty($form['multiSection'])) : // In case of multisection for the current form ?>
        <div class="widget stacked ">
        	
        	<div class="widget-header">
        		<i class="icon-flag"></i>
        		<h3><?php echo $section['legend']['title']; ?></h3>
        	</div> <!-- /widget-header -->
        	
        	<div class="widget-content">
        <?php endif;                                // [END]multisection for the current form ?>
    
            <?php if (!empty($section['tabs'])) :   // In case of tabs for the current section ?>
            <div class="tabbable">
            		<?php if (!empty($section['tabs']) && is_array($section['tabs'])) : ?>
                        <ul class="nav nav-tabs">
                        <?php foreach ($section['tabs'] as $kTab => $tab): ?>
                            <li class="active"><a href="<?php echo $form['formSettings']['action'].'#'.$tab['tabConfig']['id']; ?>" data-toggle="tab"><?php echo $tab['tabConfig']['title']; ?></a></li>
                        <?php endforeach; ?>
                		</ul>
                    <?php endif; ?>
            	<br />
                
        	    <div class="tab-content">
                
                    <!-- Each tabs -->
                    <?php foreach ($section['tabs'] as $kTab => $tab): ?>
                    <div class="tab-pane<?php echo ($kTab == 0)?' active':''; ?>" id="<?php echo $kTab; ?>">
                        <?php foreach ($tab as $tabS => $tabSection): ?>
                            <?php if (!is_int($kTab)) continue; // Removing entries that are not tabs ?>
                		<fieldset id="edit-<?php echo $kTab; ?>" class="form-horizontal col-md-12">
                            <legend class="block_head">
                                <?php echo $tabSection['legend']['title'] ; ?>
                            </legend>
                            <div class="block_content" id="content_<?php echo $kSect; ?>">
                            <?php foreach ($tabSection['input'] as $kInput => $input): ?>
                          		<?php include(((BASEPATH == '/')?'':dirname(BASEPATH)).'/'.APPPATH.'views/Templates/FormHelper/formInputHelper.php'); ?>
                            <?php endforeach; ?>
                            </div>
                		</fieldset>
                        <?php endforeach; ?>
                    </div>
                    <?php endforeach; ?>
                    <!-- /Each tabs -->
            <?php endif;                           // [END]In case of tabs for the current section ?>
                
        		<fieldset id="edit-profile" class="form-horizontal col-md-12">
                    <legend class="block_head">
                        <?php echo $section['legend']['title'] ; ?>
                    </legend>
                    <div class="block_content" id="content_<?php echo $kSect; ?>">
                    <?php foreach ($section['input'] as $kInput => $input): ?>
                  		<?php include(((BASEPATH == '/')?'':dirname(BASEPATH)).'/'.APPPATH.'views/Templates/FormHelper/formInputHelper.php'); ?>
                    <?php endforeach; ?>
                    </div>
        		</fieldset>
        
            <?php if (!empty($section['tabs'])) :  // In case of tabs for the current section ?>
                </div>
            </div> <!-- /tabbable -->
            <?php endif;                           // [END]In case of tabs for the current section ?>
        
        <?php if (!empty($form['multiSection'])) : // In case of multisection for the current form ?>
        	</div> <!-- /widget-content -->
        		
        </div> <!-- /widget -->
        <?php endif;                               // [END]In case of multisection for the current form ?>
    
    <?php endforeach;                              // [END]Each section  ?>

    <div class="clear"></div>
    <hr /><br />
    
	<div class="form-horizontal form-group <?php echo (!empty($form['multiSection'])) ? 'col-md-12' : 'col-md-8'; ?>" style=" padding: 0; ">
		<div class="<?php echo (!empty($form['multiSection'])) ? 'col-md-offset-8 col-med-4' : 'col-md-offset-4 col-md-8'; ?>">
			<button type="submit" class="btn btn-primary" name="btn_submit"><?php echo $form['actionBtn']['submit']['title']; ?></button> 
            <a class="btn btn-default" href="<?php echo $form['actionBtn']['cancel']['href']; ?>"><?php echo $form['actionBtn']['cancel']['title']; ?></a>
		</div>
	</div>
    
</form>


<script src="<?php echo base_url('webroot/js/jquery/jquery-1.9.1.min.js'); ?>"></script>
<script src="<?php echo base_url('webroot/js/jquery/jquery.validate.js'); ?>"></script>


<script src="<?php echo base_url('webroot/js/Application.js'); ?>"></script>
<script src="<?php echo base_url('webroot/js/validation.js'); ?>"></script>

<script>

$(function () {

	// Validate the form on load
	//$('#validation-form').submit ();

	// Block the form from submitting
	/*$('form').submit (function (e) {
		e.preventDefault ();
	});*/
    
    // Toogle languages
    $('.form-flag a.lang_flag').click(function () {
        if ($(this).is('.current_lang')) {
            // Show all available lang by displaying the flags
            $(this).parent('.form-flag').children('a.lang_flag').each(function () {
                $(this).removeClass('current_lang');
                $(this).show();
            });
        } else {
            // Choosing a language
            $('.form-flag').children('a.lang_flag').each(function () {
                $(this).removeClass('current_lang');
                $(this).hide();
                $('.input_'+ $(this).attr('data-lang')).hide();
            });
            
            // Display the selected lang for all fields
            $('.form-flag a.lang_flag[data-lang='+ $(this).attr('data-lang') +']').show();
            $('.form-flag a.lang_flag[data-lang='+ $(this).attr('data-lang') +']').addClass('current_lang');
            $('.input_'+ $(this).attr('data-lang')).show();
        }
    });

});

</script>

